const webpack = require('webpack')
const merge = require('webpack-merge')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
var FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin')
const MinifyPlugin = require("babel-minify-webpack-plugin")
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')

// process.env.BABEL_ENV = 'production'

module.exports = merge.smart(require('./webpack.base.config'), {
    devtool: 'source-map',
    module: {
        rules: [{
            test: /\.css$/,
            use: ExtractTextPlugin.extract({
                fallback: "style-loader",
                use: "css-loader"
            })
        }]
    },
    plugins: [
        new webpack.DefinePlugin({
            env: JSON.stringify('production')
        }),
        // new MinifyPlugin({}, {sourceMap: ''}),
        // new webpack.optimize.UglifyJsPlugin({
        //     compress: {
        //         warnings: false
        //     },
        //     sourceMap: false
        // }),
        new FriendlyErrorsWebpackPlugin(),
        new ExtractTextPlugin("styles.css"),
        new OptimizeCssAssetsPlugin()
        // new BundleAnalyzerPlugin()
    ]
})
